---
title: 打印
icon: '#pro/Printer'
---

<MetaData
  lang="zh-CN"
  isPro
  meta={{
    preset: [{
      client: '@univerjs/preset-docs-advanced',
      locale: '@univerjs/preset-docs-advanced/locales/zh-CN',
      style: '@univerjs/preset-docs-advanced/lib/index.css',
    }],
    plugins: [{
      client: '@univerjs-pro/docs-print',
      locale: '@univerjs-pro/docs-print/locale/zh-CN',
    }],
    server: '否',
  }}
/>

打印功能允许用户将文档内容打印为纸质文档或导出为 PDF 格式，便于离线查看和分享。

## 预设模式

打印功能被包含在 `@univerjs/preset-docs-advanced` 预设中。

### 安装

<Callout>
  @univerjs/preset-docs-advanced 的 `UniverDocsAdvancedPreset` 预设在运行时依赖 `UniverDocsDrawingPreset` 预设，请先安装 @univerjs/preset-docs-drawing。
</Callout>

```package-install
npm install @univerjs/preset-docs-drawing @univerjs/preset-docs-advanced
```

### 使用

```typescript
import { UniverDocsAdvancedPreset } from '@univerjs/preset-docs-advanced' // [!code ++]
import UniverPresetDocsAdvancedZhCN from '@univerjs/preset-docs-advanced/locales/zh-CN' // [!code ++]
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'
import UniverPresetDocsCoreZhCN from '@univerjs/preset-docs-core/locales/zh-CN'
import { UniverDocsDrawingPreset } from '@univerjs/preset-docs-drawing' // [!code ++]
import UniverPresetDocsDrawingZhCN from '@univerjs/preset-docs-drawing/locales/zh-CN' // [!code ++]
import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'

import '@univerjs/preset-docs-core/lib/index.css'
import '@univerjs/preset-docs-drawing/lib/index.css' // [!code ++]
import '@univerjs/preset-docs-advanced/lib/index.css' // [!code ++]

const { univerAPI } = createUniver({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      UniverPresetDocsCoreZhCN,
      UniverPresetDocsDrawingZhCN, // [!code ++]
      UniverPresetDocsAdvancedZhCN, // [!code ++]
    ),
  },
  presets: [
    UniverDocsCorePreset(),
    UniverDocsDrawingPreset(), // [!code ++]
    UniverDocsAdvancedPreset(), // [!code ++]
  ],
})
```

如果你拥有 Univer 的商业许可证，请参考[在客户端使用许可证](/guides/pro/license#在预设模式中使用)进行配置。

{/* ### 预设与配置 */}

## 插件模式

### 安装

```package-install
npm install @univerjs-pro/docs-print
```

### 使用

```typescript
import { UniverDocsPrintPlugin } from '@univerjs-pro/docs-print' // [!code ++]
import DocsPrintPluginZhCN from '@univerjs-pro/docs-print/locale/zh-CN' // [!code ++]
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'

import '@univerjs-pro/docs-print/lib/index.css' // [!code ++]

const univer = new Univer({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      DocsPrintPluginZhCN, // [!code ++]
    ),
  },
})

univer.registerPlugin(UniverDocsPrintPlugin) // [!code ++]
```

如果你拥有 Univer 的商业许可证，请参考[在客户端使用许可证](/guides/pro/license#在插件模式中使用)进行配置。

{/* ### 插件与配置 */}
